//
//  ViewController.m
//  UI21_02_Block实现页面间传值
//
//  Created by Scott on 16/4/7.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

/** push 到下一个页面调用此方法. */
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    
    // 获取第二页面对象.
    VCOfSecond *second = [segue destinationViewController];
    
    // Block 实现
    // Block 实现体中, 对对象进行强引用, 避免循环引用, 修改为弱引用.
    // ARC下, __weak 修饰词.
    // MRC下, __block 修饰词.
    
    __weak typeof(self) weakself = self;
    second.handleString = ^(NSString *str) {
        
        weakself.label.text = str;

    };

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
